// __PUBLIC__/js/page/weiba/admin/weibaadminaudit
require(['../../common'], function() {
  require(['admin.weibaadminaudit'])
})

define('admin.weibaadminaudit', [
  'jquery'
], function($) {
  'use strict';


  function ajaxReload(obj, callback) {
    if ("undefined" == typeof(callback)) {
      callback = "location.href = location.href";
    } else {
      callback = 'eval(' + callback + ')';
    }
    if (obj.status == 1) {
      alert(obj.data);
      setTimeout(callback, 1500);
    } else {
      ui.error(obj.data);
    }
  };

  /**
   * 吧主审核
   */

  function doAudit(weiba_id, uid, value) {
    $.post(APP + '?app=weiba&m=Manage&a=verify', {
      weiba_id: weiba_id,
      uid: uid,
      value: value
    }, function(msg) {
      ajaxReload(msg);
    }, 'json');
  }

  $(document)
  .on('click', '.A_taudit, .A_baudit', function(e) {
    e.preventDefault()
    var weiba_id = $(this).closest('tr').data('id')
    var followeruid = $(this).data('followeruid')
    var type = $(this).data('type')

    doAudit(weiba_id, followeruid, type)
  })
})